


#include <iostream>
using namespace std;

int compare(const void* p1, const void* p2)
{
    return *((int*)p1) - *((int*)p2);
}

int findLHS(int* nums, int sz)
{
    if (1 == sz)
        return 0;

    qsort(nums, sz, sizeof(nums[0]), compare);

    int ans = 0;
    int left = 0, right = 1;
    while (right < sz)
    {
        while (right < sz && nums[right] - nums[left] <= 1)
        {
            ++right;
        }
        if (1 == nums[right - 1] - nums[left])
            ans = fmax(ans, right - left);

        while (right < sz && nums[right] - nums[left] > 1)
        {
            ++left;
        }
        ++right;
    }

    return ans;
}

int main()
{

	return 0;
}